package com.fxp.project.jiuselu.web.models.goods.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.fxp.project.jiuselu.web.models.goods.entity.JslGoods;
import com.fxp.project.jiuselu.web.models.goods.mapper.JslGoodsMapper;
import com.fxp.project.jiuselu.web.models.goods.service.IJslGoodsService;
import com.fxp.project.jiuselu.web.models.goods.vo.GoodsListVo;
import com.fxp.project.jiuselu.web.models.goods.vo.GoodsVo;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.time.LocalDateTime;
import java.util.List;

/**
 * <p>
 * 主商品表 服务实现类
 * </p>
 *
 * @author Jason.Wang
 * @since 2021-11-01
 */
@Service
public class JslGoodsServiceImpl extends ServiceImpl<JslGoodsMapper, JslGoods> implements IJslGoodsService {


    JslGoodsMapper jslGoodsMapper;

    @Autowired
    public void setJslGoodsMapper(JslGoodsMapper jslGoodsMapper) {
        this.jslGoodsMapper = jslGoodsMapper;
    }

    /**
     * selectGoodsListPageInfo: 查询当亲的产品分类<br/>
     *
     * @param cateId
     * @param extendCateId
     * @param thirdCateId
     * @param discover
     * @param sample
     * @param keyword
     * @param currentPage
     * @param pageSize
     * @param currentDate
     * @return
     * @author Jason.Wang
     * @date 2021/11/6 11:07 上午
     */
    @Override
    public PageInfo<GoodsListVo> selectGoodsListPageInfo(Long cateId, Long extendCateId, long thirdCateId,
        Integer discover, Integer sample, String keyword, Integer currentPage, Integer pageSize,
        LocalDateTime currentDate,Integer salesCount,Integer attrPrice,Integer goodsSort) {

        List<GoodsListVo> list =
            jslGoodsMapper.selectGoodsListPageInfo(cateId, extendCateId, thirdCateId, discover, sample, keyword,
                currentDate,salesCount,attrPrice,goodsSort);
//        PageHelper.startPage(currentPage, pageSize);
        return new PageInfo<>(list);
    }

    /**
     * selectGoodsVoByGoodsId: 获取当前商品的详细信息<br/>
     *
     * @param goodsId
     * @return
     * @author Jason.Wang
     * @date 2021/11/7 10:17 上午
     */
    @Override
    public GoodsVo selectGoodsVoByGoodsId(Long goodsId) {
        return jslGoodsMapper.selectGoodsVoByGoodsId(goodsId);
    }
}
